package com.example.crm.controller;

import com.example.crm.entity.Opportunity;
import com.example.crm.service.OpportunityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 销售机会页面控制器
 */
@Controller
@RequestMapping("/opportunity")
public class OpportunityViewController {

    @Autowired
    private OpportunityService opportunityService;

    /**
     * 销售机会列表页面
     */
    @GetMapping("/list")
    public String list() {
        return "opportunity/list";
    }

    /**
     * 销售机会新增页面
     */
    @GetMapping("/add")
    public String add() {
        return "opportunity/add";
    }

    /**
     * 销售机会编辑页面
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable Long id, Model model) {
        model.addAttribute("opportunity", opportunityService.getOpportunityDetail(id));
        return "opportunity/edit";
    }

    /**
     * 销售机会详情页面
     */
    @GetMapping("/detail/{id}")
    public String detail(@PathVariable Long id, Model model) {
        model.addAttribute("opportunity", opportunityService.getOpportunityDetail(id));
        return "opportunity/detail";
    }
} 